using SS.core;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Drawing.Printing;
using System.Globalization;
using System.Threading;
using System.Windows.Forms;
namespace SS
{
	public class frmRepProductProvider : Form
	{
		private IContainer components = null;
		private TextBox txtreTailPrice;
		private Label label9;
		private TextBox txtSalePrice;
		private Label label8;
		private TextBox txtInputPrice;
		private Label label7;
		private Button tSBClose;
		private DataGridView dgvRep;
		private ComboBox cbbList;
		private TextBox txtSearch;
		private Label label2;
		private Button btnShowAll;
		private TreeView tvGroup;
		private ImageList imageList1;
		private Label label3;
		private DataGridView dgvProvider;
		private DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
		private Label label1;
		private Label lblCountProvider;
		private Button btnPrint;
		private DataGridViewCheckBoxColumn dg1;
		private DataGridViewTextBoxColumn dg2;
		private DataGridViewTextBoxColumn Column1;
		private DataGridViewTextBoxColumn dg6;
		private Func objFunc = new Func();
		public int ProductID = 0;
		private EAN13CodeCtl eaN13CodeCtl1;
		private int m_X = 11;
		private int m_Y = 55;
		private int m_Width = 225;
		private int m_Height = 103;
		private int CurrBarcodeNumberPrinted = 0;
		private int BarcodeNumber = 0;
		private PrintDocument printDocument1;
		private int currGroup = 0;
		private products objP = new products();
		private bool loaded = false;
		private float m_Scale = 0.8f;
		public bool checkChange = false;
		public bool fastAdd = false;
		public string NameOfNewProduct = "";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.components = new Container();
			DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle5 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle6 = new DataGridViewCellStyle();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmRepProductProvider));
			DataGridViewCellStyle dataGridViewCellStyle7 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle8 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle9 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle10 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle11 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle12 = new DataGridViewCellStyle();
			this.printDocument1 = new PrintDocument();
			this.txtreTailPrice = new TextBox();
			this.label9 = new Label();
			this.txtSalePrice = new TextBox();
			this.label8 = new Label();
			this.txtInputPrice = new TextBox();
			this.label7 = new Label();
			this.tSBClose = new Button();
			this.dgvRep = new DataGridView();
			this.dg1 = new DataGridViewCheckBoxColumn();
			this.dg2 = new DataGridViewTextBoxColumn();
			this.Column1 = new DataGridViewTextBoxColumn();
			this.dg6 = new DataGridViewTextBoxColumn();
			this.cbbList = new ComboBox();
			this.txtSearch = new TextBox();
			this.label2 = new Label();
			this.btnShowAll = new Button();
			this.tvGroup = new TreeView();
			this.imageList1 = new ImageList(this.components);
			this.label3 = new Label();
			this.dgvProvider = new DataGridView();
			this.dataGridViewCheckBoxColumn1 = new DataGridViewCheckBoxColumn();
			this.dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
			this.label1 = new Label();
			this.lblCountProvider = new Label();
			this.btnPrint = new Button();
			((ISupportInitialize)this.dgvRep).BeginInit();
			((ISupportInitialize)this.dgvProvider).BeginInit();
			base.SuspendLayout();
			this.printDocument1.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage);
			this.txtreTailPrice.BackColor = Color.White;
			this.txtreTailPrice.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.txtreTailPrice.Location = new Point(412, 313);
			this.txtreTailPrice.Name = "txtreTailPrice";
			this.txtreTailPrice.Size = new Size(96, 22);
			this.txtreTailPrice.TabIndex = 7;
			this.txtreTailPrice.Text = "0";
			this.txtreTailPrice.TextAlign = HorizontalAlignment.Right;
			this.txtreTailPrice.Leave += new EventHandler(this.txtreTailPrice_Leave);
			this.txtreTailPrice.KeyPress += new KeyPressEventHandler(this.txtreTailPrice_KeyPress);
			this.txtreTailPrice.Enter += new EventHandler(this.txtreTailPrice_Enter);
			this.label9.AutoSize = true;
			this.label9.Location = new Point(439, 320);
			this.label9.Name = "label9";
			this.label9.Size = new Size(69, 15);
			this.label9.TabIndex = 14;
			this.label9.Text = "Giá bán lẻ :";
			this.txtSalePrice.BackColor = Color.White;
			this.txtSalePrice.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.txtSalePrice.Location = new Point(300, 317);
			this.txtSalePrice.Name = "txtSalePrice";
			this.txtSalePrice.Size = new Size(96, 22);
			this.txtSalePrice.TabIndex = 6;
			this.txtSalePrice.Text = "0";
			this.txtSalePrice.TextAlign = HorizontalAlignment.Right;
			this.txtSalePrice.Leave += new EventHandler(this.txtSalePrice_Leave);
			this.txtSalePrice.KeyPress += new KeyPressEventHandler(this.txtSalePrice_KeyPress);
			this.txtSalePrice.Enter += new EventHandler(this.txtSalePrice_Enter);
			this.label8.AutoSize = true;
			this.label8.Location = new Point(210, 320);
			this.label8.Name = "label8";
			this.label8.Size = new Size(87, 15);
			this.label8.TabIndex = 12;
			this.label8.Text = "Giá bán buôn :";
			this.txtInputPrice.BackColor = Color.White;
			this.txtInputPrice.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.txtInputPrice.Location = new Point(284, 317);
			this.txtInputPrice.Name = "txtInputPrice";
			this.txtInputPrice.Size = new Size(108, 22);
			this.txtInputPrice.TabIndex = 5;
			this.txtInputPrice.Text = "0";
			this.txtInputPrice.TextAlign = HorizontalAlignment.Right;
			this.txtInputPrice.Leave += new EventHandler(this.txtInputPrice_Leave);
			this.txtInputPrice.KeyPress += new KeyPressEventHandler(this.txtInputPrice_KeyPress);
			this.txtInputPrice.Enter += new EventHandler(this.txtInputPrice_Enter);
			this.label7.AutoSize = true;
			this.label7.Location = new Point(218, 320);
			this.label7.Name = "label7";
			this.label7.Size = new Size(63, 15);
			this.label7.TabIndex = 10;
			this.label7.Text = "Giá nhập :";
			this.tSBClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.tSBClose.BackColor = SystemColors.ControlLight;
			this.tSBClose.Cursor = Cursors.Hand;
			this.tSBClose.FlatAppearance.BorderColor = Color.Gray;
			this.tSBClose.FlatStyle = FlatStyle.System;
			this.tSBClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.tSBClose.ImageAlign = ContentAlignment.MiddleLeft;
//			this.tSBClose.ImeMode = ImeMode.NoControl;
			this.tSBClose.Location = new Point(799, 565);
			this.tSBClose.Name = "tSBClose";
			this.tSBClose.Size = new Size(95, 28);
			this.tSBClose.TabIndex = 20;
			this.tSBClose.Text = "Thoát  [ ESC ]";
			this.tSBClose.UseVisualStyleBackColor = false;
			this.tSBClose.Click += new EventHandler(this.tSBClose_Click);
			this.dgvRep.AllowUserToAddRows = false;
			this.dgvRep.AllowUserToDeleteRows = false;
			this.dgvRep.AllowUserToResizeColumns = false;
			this.dgvRep.AllowUserToResizeRows = false;
			dataGridViewCellStyle.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.dgvRep.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
			this.dgvRep.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left);
			this.dgvRep.BackgroundColor = Color.White;
			this.dgvRep.BorderStyle = BorderStyle.Fixed3D;
			this.dgvRep.CellBorderStyle = DataGridViewCellBorderStyle.Raised;
			this.dgvRep.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
			dataGridViewCellStyle2.BackColor = SystemColors.Control;
			dataGridViewCellStyle2.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle2.ForeColor = SystemColors.WindowText;
			dataGridViewCellStyle2.SelectionBackColor = Color.Aqua;
			dataGridViewCellStyle2.SelectionForeColor = Color.Black;
			this.dgvRep.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
			this.dgvRep.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.dgvRep.Columns.AddRange(new DataGridViewColumn[]
			{
				this.dg1,
				this.dg2,
				this.Column1,
				this.dg6
			});
			this.dgvRep.Cursor = Cursors.Hand;
			this.dgvRep.Location = new Point(202, 46);
			this.dgvRep.MultiSelect = false;
			this.dgvRep.Name = "dgvRep";
			this.dgvRep.ReadOnly = true;
			dataGridViewCellStyle3.BackColor = SystemColors.Control;
			dataGridViewCellStyle3.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle3.ForeColor = Color.Black;
			dataGridViewCellStyle3.SelectionBackColor = Color.Aqua;
			dataGridViewCellStyle3.SelectionForeColor = Color.Black;
			this.dgvRep.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
			this.dgvRep.RowHeadersVisible = false;
			this.dgvRep.RowHeadersWidth = 26;
			this.dgvRep.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			dataGridViewCellStyle4.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvRep.RowsDefaultCellStyle = dataGridViewCellStyle4;
			this.dgvRep.RowTemplate.DefaultCellStyle.BackColor = Color.White;
			this.dgvRep.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.dgvRep.RowTemplate.DefaultCellStyle.ForeColor = Color.Black;
			this.dgvRep.RowTemplate.DefaultCellStyle.SelectionBackColor = Color.Aqua;
			this.dgvRep.RowTemplate.DefaultCellStyle.SelectionForeColor = Color.Black;
			this.dgvRep.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvRep.Size = new Size(306, 546);
			this.dgvRep.TabIndex = 21;
			this.dgvRep.CellEnter += new DataGridViewCellEventHandler(this.dgvRep_CellEnter);
			this.dg1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dg1.DataPropertyName = "TT";
			dataGridViewCellStyle5.Alignment = DataGridViewContentAlignment.MiddleCenter;
			dataGridViewCellStyle5.NullValue = "False";
			this.dg1.DefaultCellStyle = dataGridViewCellStyle5;
			this.dg1.FalseValue = "0";
			this.dg1.HeaderText = "";
			this.dg1.IndeterminateValue = "0";
			this.dg1.Name = "dg1";
			this.dg1.ReadOnly = true;
			this.dg1.Resizable = DataGridViewTriState.False;
			this.dg1.TrueValue = "1";
			this.dg1.Visible = false;
			this.dg1.Width = 30;
			this.dg2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dg2.DataPropertyName = "P_Name";
			dataGridViewCellStyle6.Alignment = DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle6.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle6.NullValue = null;
			this.dg2.DefaultCellStyle = dataGridViewCellStyle6;
			this.dg2.HeaderText = "Tên sản phẩm";
			this.dg2.MinimumWidth = 120;
			this.dg2.Name = "dg2";
			this.dg2.ReadOnly = true;
			this.Column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column1.DataPropertyName = "UnitName";
			this.Column1.HeaderText = "Đơn vị tính";
			this.Column1.MinimumWidth = 80;
			this.Column1.Name = "Column1";
			this.Column1.ReadOnly = true;
			this.Column1.Width = 80;
			this.dg6.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dg6.DataPropertyName = "PID";
			this.dg6.HeaderText = "PID";
			this.dg6.Name = "dg6";
			this.dg6.ReadOnly = true;
			this.dg6.Resizable = DataGridViewTriState.False;
			this.dg6.Visible = false;
			this.dg6.Width = 5;
			this.cbbList.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbList.Font = new Font("Arial", 12.75f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.cbbList.FormattingEnabled = true;
			this.cbbList.Items.AddRange(new object[]
			{
				"TẨT CẢ",
				"------ A",
				"------ B",
				"------ C",
				"------ D",
				"------ E",
				"------ F",
				"------ G",
				"------ H",
				"------ I",
				"------ J",
				"------ K",
				"------ L",
				"------ M",
				"------ N",
				"------ O",
				"------ P",
				"------ Q",
				"------ R",
				"------ S",
				"------ T",
				"------ U",
				"------ V",
				"------ W",
				"------ X",
				"------ Y",
				"------ Z"
			});
			this.cbbList.Location = new Point(201, 15);
			this.cbbList.Name = "cbbList";
			this.cbbList.Size = new Size(80, 27);
			this.cbbList.TabIndex = 125;
			this.cbbList.SelectedIndexChanged += new EventHandler(this.cbbList_SelectedIndexChanged);
			this.txtSearch.AcceptsReturn = true;
			this.txtSearch.Font = new Font("Arial", 11.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtSearch.Location = new Point(285, 16);
			this.txtSearch.Name = "txtSearch";
			this.txtSearch.Size = new Size(136, 25);
			this.txtSearch.TabIndex = 126;
			this.txtSearch.TextChanged += new EventHandler(this.txtSearch_TextChanged);
			this.label2.BackColor = Color.FromArgb(255, 255, 192);
			this.label2.BorderStyle = BorderStyle.Fixed3D;
			this.label2.Location = new Point(5, 16);
			this.label2.Name = "label2";
			this.label2.Size = new Size(191, 24);
			this.label2.TabIndex = 127;
			this.label2.Text = "Tìm kiếm sản phẩm :";
			this.label2.TextAlign = ContentAlignment.MiddleRight;
			this.btnShowAll.FlatAppearance.BorderColor = Color.FromArgb(128, 128, 255);
			this.btnShowAll.FlatStyle = FlatStyle.Flat;
			this.btnShowAll.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnShowAll.Location = new Point(426, 17);
			this.btnShowAll.Name = "btnShowAll";
			this.btnShowAll.Size = new Size(82, 24);
			this.btnShowAll.TabIndex = 128;
			this.btnShowAll.Text = "Xem tất cả";
			this.btnShowAll.UseVisualStyleBackColor = true;
			this.btnShowAll.Click += new EventHandler(this.btnShowAll_Click);
			this.tvGroup.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left);
			this.tvGroup.ImageIndex = 0;
//			this.tvGroup.ImageList = this.imageList1;
			this.tvGroup.Location = new Point(5, 46);
			this.tvGroup.Name = "tvGroup";
			this.tvGroup.SelectedImageIndex = 0;
			this.tvGroup.Size = new Size(191, 546);
			this.tvGroup.TabIndex = 129;
			this.tvGroup.AfterSelect += new TreeViewEventHandler(this.tvGroup_AfterSelect);
//			this.imageList1.ImageStream = (ImageListStreamer)componentResourceManager.GetObject("imageList1.ImageStream");
			this.imageList1.TransparentColor = Color.Transparent;
			this.imageList1.Images.SetKeyName(0, "star_2.png");
			this.imageList1.Images.SetKeyName(1, "31.png");
			this.label3.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.label3.BorderStyle = BorderStyle.FixedSingle;
			this.label3.Location = new Point(514, 559);
			this.label3.Name = "label3";
			this.label3.Size = new Size(380, 1);
			this.label3.TabIndex = 130;
			this.dgvProvider.AllowUserToAddRows = false;
			this.dgvProvider.AllowUserToDeleteRows = false;
			this.dgvProvider.AllowUserToResizeColumns = false;
			this.dgvProvider.AllowUserToResizeRows = false;
			dataGridViewCellStyle7.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle7.Font = new Font("Arial", 11.25f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.dgvProvider.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle7;
			this.dgvProvider.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.dgvProvider.BackgroundColor = Color.White;
			this.dgvProvider.BorderStyle = BorderStyle.Fixed3D;
			this.dgvProvider.CellBorderStyle = DataGridViewCellBorderStyle.Raised;
			this.dgvProvider.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
			dataGridViewCellStyle8.BackColor = SystemColors.Control;
			dataGridViewCellStyle8.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle8.ForeColor = SystemColors.WindowText;
			dataGridViewCellStyle8.SelectionBackColor = Color.Aqua;
			dataGridViewCellStyle8.SelectionForeColor = Color.Black;
			this.dgvProvider.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8;
			this.dgvProvider.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.dgvProvider.Columns.AddRange(new DataGridViewColumn[]
			{
				this.dataGridViewCheckBoxColumn1,
				this.dataGridViewTextBoxColumn1,
				this.dataGridViewTextBoxColumn2
			});
			this.dgvProvider.Cursor = Cursors.Hand;
			this.dgvProvider.Location = new Point(514, 46);
			this.dgvProvider.MultiSelect = false;
			this.dgvProvider.Name = "dgvProvider";
			this.dgvProvider.ReadOnly = true;
			dataGridViewCellStyle9.BackColor = SystemColors.Control;
			dataGridViewCellStyle9.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle9.ForeColor = Color.Black;
			dataGridViewCellStyle9.SelectionBackColor = Color.Aqua;
			dataGridViewCellStyle9.SelectionForeColor = Color.Black;
			this.dgvProvider.RowHeadersDefaultCellStyle = dataGridViewCellStyle9;
			this.dgvProvider.RowHeadersVisible = false;
			this.dgvProvider.RowHeadersWidth = 26;
			this.dgvProvider.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			dataGridViewCellStyle10.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvProvider.RowsDefaultCellStyle = dataGridViewCellStyle10;
			this.dgvProvider.RowTemplate.DefaultCellStyle.BackColor = Color.White;
			this.dgvProvider.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 11.25f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.dgvProvider.RowTemplate.DefaultCellStyle.ForeColor = Color.Black;
			this.dgvProvider.RowTemplate.DefaultCellStyle.SelectionBackColor = Color.Aqua;
			this.dgvProvider.RowTemplate.DefaultCellStyle.SelectionForeColor = Color.Black;
			this.dgvProvider.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvProvider.Size = new Size(380, 506);
			this.dgvProvider.TabIndex = 131;
			this.dataGridViewCheckBoxColumn1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewCheckBoxColumn1.DataPropertyName = "TT";
			dataGridViewCellStyle11.Alignment = DataGridViewContentAlignment.MiddleCenter;
			dataGridViewCellStyle11.NullValue = "False";
			this.dataGridViewCheckBoxColumn1.DefaultCellStyle = dataGridViewCellStyle11;
			this.dataGridViewCheckBoxColumn1.FalseValue = "0";
			this.dataGridViewCheckBoxColumn1.HeaderText = "";
			this.dataGridViewCheckBoxColumn1.IndeterminateValue = "0";
			this.dataGridViewCheckBoxColumn1.Name = "dataGridViewCheckBoxColumn1";
			this.dataGridViewCheckBoxColumn1.ReadOnly = true;
			this.dataGridViewCheckBoxColumn1.Resizable = DataGridViewTriState.False;
			this.dataGridViewCheckBoxColumn1.TrueValue = "1";
			this.dataGridViewCheckBoxColumn1.Visible = false;
			this.dataGridViewCheckBoxColumn1.Width = 30;
			this.dataGridViewTextBoxColumn1.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dataGridViewTextBoxColumn1.DataPropertyName = "Name";
			dataGridViewCellStyle12.Alignment = DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle12.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle12.NullValue = null;
			this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle12;
			this.dataGridViewTextBoxColumn1.HeaderText = "Nhà cung cấp";
			this.dataGridViewTextBoxColumn1.MinimumWidth = 200;
			this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
			this.dataGridViewTextBoxColumn1.ReadOnly = true;
			this.dataGridViewTextBoxColumn2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.dataGridViewTextBoxColumn2.DataPropertyName = "Address";
			this.dataGridViewTextBoxColumn2.HeaderText = "Địa chỉ";
			this.dataGridViewTextBoxColumn2.MinimumWidth = 120;
			this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
			this.dataGridViewTextBoxColumn2.ReadOnly = true;
			this.label1.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.label1.BackColor = Color.FromArgb(255, 255, 192);
			this.label1.BorderStyle = BorderStyle.Fixed3D;
			this.label1.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.label1.Location = new Point(514, 16);
			this.label1.Name = "label1";
			this.label1.Size = new Size(380, 24);
			this.label1.TabIndex = 132;
			this.label1.Text = "Danh sách nhà cung cấp";
			this.label1.TextAlign = ContentAlignment.MiddleCenter;
			this.lblCountProvider.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.lblCountProvider.BackColor = Color.White;
			this.lblCountProvider.BorderStyle = BorderStyle.Fixed3D;
			this.lblCountProvider.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.lblCountProvider.Location = new Point(514, 567);
			this.lblCountProvider.Name = "lblCountProvider";
			this.lblCountProvider.Size = new Size(183, 24);
			this.lblCountProvider.TabIndex = 133;
			this.lblCountProvider.Text = "-:-";
			this.lblCountProvider.TextAlign = ContentAlignment.MiddleLeft;
			this.btnPrint.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnPrint.BackColor = SystemColors.ControlLight;
			this.btnPrint.Cursor = Cursors.Hand;
			this.btnPrint.FlatAppearance.BorderColor = Color.Gray;
			this.btnPrint.FlatStyle = FlatStyle.System;
			this.btnPrint.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnPrint.ImageAlign = ContentAlignment.MiddleLeft;
//			this.btnPrint.ImeMode = ImeMode.NoControl;
			this.btnPrint.Location = new Point(700, 565);
			this.btnPrint.Name = "btnPrint";
			this.btnPrint.Size = new Size(98, 28);
			this.btnPrint.TabIndex = 134;
			this.btnPrint.Text = "In báo cáo [ F7 ]";
			this.btnPrint.UseVisualStyleBackColor = false;
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			this.BackgroundImageLayout = ImageLayout.Stretch;
			base.ClientSize = new Size(900, 600);
			base.Controls.Add(this.btnPrint);
			base.Controls.Add(this.lblCountProvider);
			base.Controls.Add(this.label1);
			base.Controls.Add(this.dgvProvider);
			base.Controls.Add(this.label3);
			base.Controls.Add(this.tvGroup);
			base.Controls.Add(this.btnShowAll);
			base.Controls.Add(this.txtSearch);
			base.Controls.Add(this.label2);
			base.Controls.Add(this.cbbList);
			base.Controls.Add(this.dgvRep);
			base.Controls.Add(this.tSBClose);
			base.Controls.Add(this.label9);
			base.Controls.Add(this.label7);
			base.Controls.Add(this.txtInputPrice);
			base.Controls.Add(this.txtreTailPrice);
			base.Controls.Add(this.label8);
			base.Controls.Add(this.txtSalePrice);
			this.DoubleBuffered = true;
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			this.MinimumSize = new Size(900, 600);
			base.Name = "frmRepProductProvider";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "BÁO CÁO SẢN PHẨM - NHÀ CUNG CẤP";
			base.WindowState = FormWindowState.Maximized;
			base.Load += new EventHandler(this.FrmupdtProduct_Load);
			base.KeyDown += new KeyEventHandler(this.FrmupdtProduct_KeyDown);
			((ISupportInitialize)this.dgvRep).EndInit();
			((ISupportInitialize)this.dgvProvider).EndInit();
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public frmRepProductProvider()
		{
			this.eaN13CodeCtl1 = new EAN13CodeCtl();
			this.eaN13CodeCtl1.BackColor = Color.White;
			this.eaN13CodeCtl1.Location = new Point(this.m_X, this.m_Y);
			this.eaN13CodeCtl1.Name = "eaN13CodeCtl1";
			this.eaN13CodeCtl1.Size = new Size(this.m_Width, this.m_Height);
			this.eaN13CodeCtl1.TabIndex = 50;
			this.InitializeComponent();
		}
		private void tSBClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void FrmupdtProduct_Load(object sender, EventArgs e)
		{
			Program.strConnectionString = this.objFunc.strConnectionString;
			this.cbbList.SelectedIndex = 0;
			this.LoadtvGProducts();
			Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");
			try
			{
				this.cbbList.SelectedIndex = 1;
			}
			catch
			{
			}
			if (!this.fastAdd)
			{
				this.loadToListViewFirstTime(this.dgvRep);
			}
			this.loaded = true;
		}
		public void loadToListViewFirstTime(DataGridView lv)
		{
			lv.AutoGenerateColumns = false;
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			string cmdText;
			if (this.cbbList.SelectedIndex == 0)
			{
				cmdText = "SELECT TOP 100 PERCENT 0 AS TT,PID,P_Name,P_PriceBase,P_PriceTrade,P_PriceRetail,UnitName, MinBalance, MaxBalance FROM [TabProducts],[TabUnitProduct] WHERE [TabProducts].[P_DonViTinh] = [TabUnitProduct].[UnitID] ORDER BY [P_Name]";
			}
			else
			{
				cmdText = "SELECT TOP 100 PERCENT 0 AS TT,PID,P_Name,P_PriceBase,P_PriceTrade,P_PriceRetail,UnitName, MinBalance, MaxBalance FROM [TabProducts],[TabUnitProduct] WHERE SUBSTRING([TabProducts].[P_name], 1, 1) = '" + this.cbbList.Text.Replace("------ ", "") + "' AND [TabProducts].[P_DonViTinh] = [TabUnitProduct].[UnitID] ORDER BY [P_Name]";
			}
			SqlCommand selectCommand = new SqlCommand(cmdText, sqlConnection);
			SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectCommand);
			DataSet dataSet = new DataSet();
			sqlConnection.Open();
			sqlDataAdapter.Fill(dataSet);
			lv.DataSource = dataSet.Tables[0];
			sqlConnection.Close();
			sqlConnection.Dispose();
			sqlDataAdapter.Dispose();
			dataSet.Dispose();
		}
		public void searchProducts(DataGridView lv)
		{
			lv.AutoGenerateColumns = false;
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			string text;
			if (this.currGroup != 0)
			{
				text = " AND [GpID] = " + this.currGroup.ToString();
			}
			else
			{
				text = "";
			}
			string text2;
			if (this.txtSearch.Text != "")
			{
				text2 = string.Concat(new string[]
				{
					" AND (Upper(TabProducts.P_Name) LIKE N'%",
					this.txtSearch.Text.ToUpper(),
					"%' OR Upper(TabProducts.NameSearch) LIKE N'%",
					this.txtSearch.Text.ToUpper(),
					"%' ) "
				});
			}
			else
			{
				text2 = " ";
			}
			string cmdText;
			if (this.cbbList.SelectedIndex == 0)
			{
				cmdText = "SELECT TOP 100 PERCENT 0 AS TT,PID,P_Name,P_PriceBase,P_PriceTrade,P_PriceRetail,UnitName, MinBalance, MaxBalance FROM [TabProducts],[TabUnitProduct] WHERE [TabProducts].[P_DonViTinh] = [TabUnitProduct].[UnitID] " + text2 + text + " ORDER BY [P_Name]";
			}
			else
			{
				cmdText = string.Concat(new string[]
				{
					"SELECT TOP 100 PERCENT 0 AS TT,PID,P_Name,P_PriceBase,P_PriceTrade,P_PriceRetail,UnitName, MinBalance, MaxBalance FROM [TabProducts],[TabUnitProduct] WHERE SUBSTRING([TabProducts].[P_name], 1, 1) = '",
					this.cbbList.Text.Replace("------ ", ""),
					"' AND [TabProducts].[P_DonViTinh] = [TabUnitProduct].[UnitID] ",
					text2,
					text,
					"  ORDER BY [P_Name]"
				});
			}
			SqlCommand selectCommand = new SqlCommand(cmdText, sqlConnection);
			SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectCommand);
			DataSet dataSet = new DataSet();
			sqlConnection.Open();
			sqlDataAdapter.Fill(dataSet);
			lv.DataSource = dataSet.Tables[0];
			sqlConnection.Close();
			sqlConnection.Dispose();
			sqlDataAdapter.Dispose();
			dataSet.Dispose();
		}
		private void InsertProductFirst(int tmpID, string tmpName)
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			SqlConnection sqlConnection2 = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			SqlCommand sqlCommand = new SqlCommand("InsertProductToWareProduct", sqlConnection);
			sqlCommand.CommandType = CommandType.StoredProcedure;
			sqlCommand.Parameters.Add("@whID", SqlDbType.VarChar, 50);
			sqlCommand.Parameters.Add("@pID", SqlDbType.Int);
			sqlCommand.Parameters.Add("@pName", SqlDbType.NVarChar, 300);
			sqlCommand.Parameters.Add("@Month", SqlDbType.SmallInt);
			sqlCommand.Parameters.Add("@Year", SqlDbType.Int);
			SqlCommand sqlCommand2 = new SqlCommand("SELECT DISTINCT WareHouse_ID FROM TabWareHouse ", sqlConnection2);
			sqlConnection2.Open();
			SqlDataReader sqlDataReader = sqlCommand2.ExecuteReader();
			if (sqlDataReader.HasRows)
			{
				while (sqlDataReader.Read())
				{
					sqlCommand.Parameters["@whID"].Value = sqlDataReader["WareHouse_ID"].ToString();
					sqlCommand.Parameters["@pID"].Value = tmpID;
					sqlCommand.Parameters["@pName"].Value = tmpName;
					sqlCommand.Parameters["@Month"].Value = DateTime.Now.Month;
					sqlCommand.Parameters["@Year"].Value = DateTime.Now.Year;
					sqlCommand.ExecuteNonQuery();
				}
			}
			sqlDataReader.Close();
			sqlDataReader.Dispose();
			sqlConnection2.Close();
			sqlConnection.Close();
			sqlConnection2.Dispose();
			sqlConnection.Dispose();
		}
		private void txtInputPrice_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtSalePrice.Focus();
			}
		}
		private void txtSalePrice_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtreTailPrice.Focus();
			}
		}
		private void txtreTailPrice_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
			}
		}
		private void txtMinimumNumber_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
			{
				e.Handled = true;
			}
		}
		private void txtUnit_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtInputPrice.Focus();
			}
		}
		private void txtRealSalePrice_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtreTailPrice.Focus();
			}
		}
		private void txtRealretailPrice_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
			}
		}
		private void UpdateNameForSearch()
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			SqlConnection sqlConnection2 = new SqlConnection(Program.strConnectionString);
			SqlCommand sqlCommand = sqlConnection.CreateCommand();
			SqlCommand sqlCommand2 = sqlConnection2.CreateCommand();
			sqlCommand.CommandText = "SELECT PID,P_Name FROM TabProducts ";
			sqlConnection.Open();
			sqlConnection2.Open();
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			if (sqlDataReader.HasRows)
			{
				while (sqlDataReader.Read())
				{
					sqlCommand2.CommandText = "UPDATE [TabProducts] SET [NameSearch]='" + this.NameForSearch(sqlDataReader["P_Name"].ToString()) + "' WHERE [PID]=" + sqlDataReader["PID"].ToString();
					sqlCommand2.ExecuteNonQuery();
				}
			}
			sqlDataReader.Close();
			sqlDataReader.Dispose();
			sqlConnection2.Close();
			sqlConnection2.Dispose();
			sqlConnection.Close();
			sqlConnection.Dispose();
			MessageBox.Show("Bạn vừa thực hiện công việc lập mục tìm kiếm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
		}
		private string NameForSearch(string RealName)
		{
			RealName = RealName.ToLower();
			RealName = RealName.Replace("ư", "u").Replace("ứ", "u").Replace("ự", "u").Replace("ử", "u").Replace("ừ", "u").Replace("ữ", "u");
			RealName = RealName.Replace("ú", "u").Replace("ụ", "u").Replace("ủ", "u").Replace("ù", "u").Replace("ũ", "u");
			RealName = RealName.Replace("á", "a").Replace("ạ", "a").Replace("ả", "a").Replace("à", "a").Replace("ã", "a");
			RealName = RealName.Replace("â", "a").Replace("ấ", "a").Replace("ẩ", "a").Replace("ầ", "a").Replace("ậ", "a").Replace("ẫ", "a");
			RealName = RealName.Replace("ă", "a").Replace("ắ", "a").Replace("ẳ", "a").Replace("ằ", "a").Replace("ặ", "a").Replace("ẵ", "a");
			RealName = RealName.Replace("ê", "e").Replace("ế", "e").Replace("ể", "e").Replace("ề", "e").Replace("ệ", "e").Replace("ễ", "e");
			RealName = RealName.Replace("é", "e").Replace("ẹ", "e").Replace("ẻ", "e").Replace("è", "e").Replace("ẽ", "e");
			RealName = RealName.Replace("í", "i").Replace("ị", "i").Replace("ỉ", "i").Replace("ì", "i").Replace("ĩ", "i");
			RealName = RealName.Replace("ý", "y").Replace("ỵ", "y").Replace("ỷ", "y").Replace("ỳ", "y").Replace("ỹ", "y");
			RealName = RealName.Replace("ó", "o").Replace("ỏ", "o").Replace("ò", "o").Replace("ọ", "o").Replace("õ", "o");
			RealName = RealName.Replace("đ", "d");
			RealName = RealName.Replace("ơ", "o").Replace("ớ", "o").Replace("ở", "o").Replace("ờ", "o").Replace("ợ", "o").Replace("ỡ", "o");
			RealName = RealName.Replace("ô", "o").Replace("ố", "o").Replace("ổ", "o").Replace("ồ", "o").Replace("ộ", "o").Replace("ỗ", "o");
			return RealName;
		}
		private void txtInputPrice_Enter(object sender, EventArgs e)
		{
			this.txtInputPrice.BackColor = Color.Aqua;
		}
		private void txtSalePrice_Enter(object sender, EventArgs e)
		{
			this.txtSalePrice.BackColor = Color.Aqua;
		}
		private void txtreTailPrice_Enter(object sender, EventArgs e)
		{
			this.txtreTailPrice.BackColor = Color.Aqua;
		}
		private void txtInputPrice_Leave(object sender, EventArgs e)
		{
			this.txtInputPrice.BackColor = Color.White;
		}
		private void txtSalePrice_Leave(object sender, EventArgs e)
		{
			this.txtSalePrice.BackColor = Color.White;
		}
		private void txtreTailPrice_Leave(object sender, EventArgs e)
		{
			this.txtreTailPrice.BackColor = Color.White;
		}
		public void DeleteProducts(int _PID)
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			SqlCommand sqlCommand = new SqlCommand("ActionOnTabProducts", sqlConnection);
			sqlCommand.CommandType = CommandType.StoredProcedure;
			sqlCommand.Parameters.Add("@PID", SqlDbType.Int);
			sqlCommand.Parameters.Add("@Act", SqlDbType.SmallInt);
			sqlCommand.Parameters["@PID"].Value = _PID;
			sqlCommand.Parameters["@Act"].Value = 2;
			sqlConnection.Open();
			sqlCommand.ExecuteNonQuery();
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private bool CheckProductName(string productName, int tempPID)
		{
			bool result = false;
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			SqlCommand sqlCommand = new SqlCommand();
			sqlCommand.Connection = sqlConnection;
			sqlCommand.CommandText = string.Concat(new object[]
			{
				"SELECT TOP 1 P_Name FROM [TabProducts] WHERE [P_Name] = '",
				productName,
				"'  AND [PID]<>",
				tempPID
			});
			sqlConnection.Open();
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			if (sqlDataReader.HasRows)
			{
				result = true;
			}
			sqlDataReader.Close();
			sqlDataReader.Dispose();
			sqlConnection.Close();
			sqlConnection.Dispose();
			return result;
		}
		private void cbbUnitProduct_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtInputPrice.Focus();
			}
		}
		private void txtSearchFor_KeyPress(object sender, KeyPressEventArgs e)
		{
		}
		public void deleteProduct(string id)
		{
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			SqlCommand sqlCommand = new SqlCommand("DelProducts", sqlConnection);
			sqlCommand.CommandType = CommandType.StoredProcedure;
			sqlCommand.Parameters.Add("ID", SqlDbType.VarChar);
			sqlCommand.Parameters["ID"].Value = id;
			sqlCommand.ExecuteNonQuery();
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private string CheckProductExistInRep(string Pid)
		{
			string result = "";
			SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
			sqlConnection.Open();
			try
			{
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				sqlCommand.CommandText = "SELECT TOP 1 [BillID] FROM [TabDetailBill] WHERE [Pid]=" + Pid;
				SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
				while (sqlDataReader.Read())
				{
					result = sqlDataReader["BillID"].ToString();
				}
				sqlDataReader.Close();
				sqlDataReader.Dispose();
			}
			catch
			{
			}
			sqlConnection.Close();
			sqlConnection.Dispose();
			return result;
		}
		private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
		{
			PrintDocument printDocument = (PrintDocument)sender;
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			switch (this.objFunc.GetPrintBarcodeType())
			{
			case 1:
				if ((double)this.m_Scale >= 0.75)
				{
					num = 13;
					num2 = 200;
					num3 = 105;
				}
				else
				{
					if ((double)this.m_Scale >= 0.55)
					{
						num = 11;
						num2 = 164;
						num3 = 95;
					}
					else
					{
						num = 13;
						num2 = 135;
						num3 = 85;
					}
				}
				num4 = 780;
				num5 = 980;
				break;
			case 2:
				if ((double)this.m_Scale >= 0.75)
				{
					num = 15;
					num2 = 198;
					num3 = 110;
				}
				else
				{
					if ((double)this.m_Scale >= 0.55)
					{
						num = 20;
						num2 = 190;
						num3 = 110;
					}
					else
					{
						num = 23;
						num2 = 158;
						num3 = 105;
					}
				}
				num4 = 780;
				num5 = 980;
				break;
			case 3:
				num = 0;
				num2 = 130;
				num3 = 100;
				num4 = 345;
				num5 = -50;
				break;
			}
			int num6 = num;
			int num7 = 8 + this.objFunc.GetBarcodePosition();
			while (this.CurrBarcodeNumberPrinted < this.BarcodeNumber)
			{
				if (num6 < num4)
				{
					e.Graphics.DrawImage(this.eaN13CodeCtl1.GetBitmap(), num6, num7);
					this.CurrBarcodeNumberPrinted++;
					num6 += num2;
				}
				else
				{
					num6 = num;
					if (num7 >= num5)
					{
						e.HasMorePages = true;
						break;
					}
					num7 += num3;
				}
			}
		}
		private void FrmupdtProduct_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
		}
		private void btnUp_Click(object sender, EventArgs e)
		{
			if (this.eaN13CodeCtl1.Scale < 0.8f && this.dgvRep.SelectedRows.Count > 0)
			{
				this.eaN13CodeCtl1.X = (int)((double)((float)this.eaN13CodeCtl1.X * 1.25f) + 0.5);
				this.eaN13CodeCtl1.Y = (int)((double)((float)this.eaN13CodeCtl1.Y * 1.25f) + 0.5);
				this.eaN13CodeCtl1.Width = (int)((double)((float)this.eaN13CodeCtl1.Width * 1.25f) + 0.5);
				this.eaN13CodeCtl1.Height = (int)((double)((float)this.eaN13CodeCtl1.Height * 1.25f) + 0.5);
				this.eaN13CodeCtl1.Scale = this.eaN13CodeCtl1.Scale * 1.25f;
				this.m_Scale = this.eaN13CodeCtl1.Scale;
			}
		}
		private void btnDown_Click(object sender, EventArgs e)
		{
			if (this.eaN13CodeCtl1.Scale > 0.6f && this.dgvRep.SelectedRows.Count > 0)
			{
				this.eaN13CodeCtl1.X = (int)((double)((float)this.eaN13CodeCtl1.X * 0.8f) + 0.5);
				this.eaN13CodeCtl1.Y = (int)((double)((float)this.eaN13CodeCtl1.Y * 0.8f) + 0.5);
				this.eaN13CodeCtl1.Width = (int)((double)((float)this.eaN13CodeCtl1.Width * 0.8f) + 0.5);
				this.eaN13CodeCtl1.Height = (int)((double)((float)this.eaN13CodeCtl1.Height * 0.8f) + 0.5);
				this.eaN13CodeCtl1.Scale = this.eaN13CodeCtl1.Scale * 0.8f;
				this.m_Scale = this.eaN13CodeCtl1.Scale;
			}
		}
		private void dgvRep_CellEnter(object sender, DataGridViewCellEventArgs e)
		{
			if (this.loaded)
			{
				try
				{
					this.ProductID = int.Parse(this.dgvRep.Rows[this.dgvRep.CurrentRow.Index].Cells["dg6"].Value.ToString());
					this.getProviderOfProduct(this.ProductID.ToString());
				}
				catch
				{
				}
			}
		}
		private void cbbList_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.loadToListViewFirstTime(this.dgvRep);
		}
		private void txtSearch_TextChanged(object sender, EventArgs e)
		{
			if (this.loaded)
			{
				this.searchProducts(this.dgvRep);
			}
		}
		private void btnShowAll_Click(object sender, EventArgs e)
		{
			this.txtSearch.Text = "";
			this.searchProducts(this.dgvRep);
		}
		private void LoadtvGProducts()
		{
			this.tvGroup.Nodes.Clear();
			string text = "";
			SqlConnection sqlConnection = new SqlConnection(this.objFunc.strConnectionString);
			sqlConnection.Open();
			if (text == "")
			{
				text = "SELECT * FROM [TabGproducts] ORDER BY [GpName]";
			}
			SqlCommand sqlCommand = new SqlCommand(text, sqlConnection);
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			TreeNode treeNode = new TreeNode();
			treeNode = new TreeNode("Nhóm thuốc");
			treeNode.Name = "0";
			treeNode.ImageIndex = 0;
			treeNode.ExpandAll();
			if (sqlDataReader.HasRows)
			{
				while (sqlDataReader.Read())
				{
					TreeNode treeNode2 = new TreeNode();
					treeNode2.ImageIndex = 0;
					treeNode2.SelectedImageIndex = 1;
					treeNode2.ExpandAll();
					treeNode2.ForeColor = Color.Black;
					treeNode2.Text = sqlDataReader["GpName"].ToString();
					treeNode2.Name = sqlDataReader["GpID"].ToString();
					treeNode.Nodes.Add(treeNode2);
				}
			}
			sqlDataReader.Close();
			sqlDataReader.Dispose();
			this.tvGroup.Nodes.Add(treeNode);
			sqlConnection.Close();
			sqlConnection.Dispose();
		}
		private void tvGroup_AfterSelect(object sender, TreeViewEventArgs e)
		{
			try
			{
				this.currGroup = int.Parse(this.tvGroup.SelectedNode.Name);
				this.searchProducts(this.dgvRep);
			}
			catch
			{
			}
		}
		public void getProviderOfProduct(string pID)
		{
			try
			{
				this.dgvProvider.AutoGenerateColumns = false;
				SqlConnection sqlConnection = new SqlConnection(Program.strConnectionString);
				sqlConnection.Open();
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				sqlCommand.CommandText = "SELECT DISTINCT [Name],[Address] FROM [TabPartner] WHERE [ProID] IN (SELECT PID FROM [TabBill] WHERE [ID] IN (SELECT [billID] FROM [TabDetailBill] WHERE [Pid] = " + this.ProductID.ToString() + ") )";
				SqlDataAdapter sqlDataAdapter = new SqlDataAdapter();
				sqlDataAdapter.SelectCommand = sqlCommand;
				DataSet dataSet = new DataSet();
				sqlDataAdapter.Fill(dataSet, "TabPartner");
				this.dgvProvider.DataSource = dataSet.Tables["TabPartner"];
				sqlConnection.Close();
				sqlConnection.Dispose();
				this.lblCountProvider.Text = "  ..:  Có " + this.dgvProvider.Rows.Count.ToString() + " nhà cung cấp cho sản phẩm được chọn";
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
	}
}
